/* --- 全局样式 & 变量 --- */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --background-color: #f8f9fa;
    --sidebar-bg: #fff;
    --content-bg: #fff;
    --details-bg: #fff;
    --border-color: #dee2e6;
    --font-color: #212529;
    --font-color-light: #6c757d;
    --hover-bg: #e9ecef;
    --selected-bg: #cce5ff;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, .075);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--font-color);
    font-size: 14px;
}

/* --- 主布局 --- */
.main-container {
    display: grid;
    grid-template-columns: 240px 1fr 300px;
    height: 100vh;
    overflow: hidden;
}

/* --- 侧边栏 (左 & 右) --- */
.sidebar, .details-pane {
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}
.details-pane {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.sidebar-header, .details-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.tree-view {
    padding: 1rem;
    overflow-y: auto;
}

/* --- 中间内容区 --- */
.content {
    display: flex;
    flex-direction: column;
    background-color: var(--content-bg);
}

.content-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.home-btn {
    font-weight: 600;
    text-decoration: none;
    color: var(--primary-color);
}

.file-browser {
    flex-grow: 1;
    overflow-y: auto;
}

/* --- 文件表格 --- */
table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background-color: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
}

tbody tr {
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}
tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background-color: var(--hover-bg);
}

tbody tr.selected {
    background-color: var(--selected-bg);
}


tbody td {
    padding: 0.5rem 1rem;
    vertical-align: middle;
}

td a {
    text-decoration: none;
    color: var(--font-color);
    display: flex;
    align-items: center;
}
td a:hover {
    color: var(--primary-color);
}

.file-icon {
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

.empty-folder {
    text-align: center;
    padding: 2rem;
    color: var(--font-color-light);
}

/* --- 右侧详情面板 --- */
#details-content {
    padding: 1rem;
    flex-grow: 1;
    overflow-y: auto;
}
.details-header {
    text-align: center;
    margin-bottom: 1rem;
}
.details-header .file-icon {
    font-size: 3rem;
    display: block;
    margin: 0 auto 0.5rem;
}
.details-header h3 {
    margin: 0;
    word-break: break-all;
}
.details-body p {
    margin: 0.5rem 0;
}
.qr-code {
    text-align: center;
    margin-top: 1.5rem;
}
.qr-code img {
    max-width: 150px;
    height: auto;
    border: 1px solid var(--border-color);
    padding: 5px;
}
.qr-code p {
    font-size: 0.8rem;
    color: var(--font-color-light);
}

.placeholder, .error {
    text-align: center;
    margin-top: 2rem;
    color: var(--font-color-light);
}

.btn {
    display: block;
    width: 100%;
    padding: 0.5rem;
    text-align: center;
    text-decoration: none;
    border-radius: 0.25rem;
    border: 1px solid transparent;
    cursor: pointer;
    margin-top: 1rem;
}
.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}
.btn-secondary {
    background-color: var(--secondary-color);
    color: #fff;
    padding: 0.25rem 0.5rem;
    display: inline-block;
    width: auto;
    margin: 0;
}

/* --- 左侧文件树样式 --- */
.tree-view ul {
    list-style: none;
    padding-left: 1rem;
    margin: 0;
}
.tree-view li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 2px 0;
}
.tree-view a {
    text-decoration: none;
    color: var(--font-color);
    display: inline-flex;
    align-items: center;
    padding: 4px 6px;
    border-radius: 4px;
    flex-grow: 1; /* Changed from width: 100% */
}
.tree-view li.active > a, .tree-root.active {
    background-color: var(--selected-bg);
    font-weight: 600;
}
.tree-view a:hover {
    background-color: var(--hover-bg);
}
.tree-view .subtree {
    display: none;
    flex-basis: 100%; /* Ensure subtree takes full width on a new line */
}
.tree-view li.open > .subtree {
    display: block;
}
.tree-view .toggle {
    cursor: pointer;
    width: 1.5em;
    text-align: center;
    transition: transform 0.1s ease;
    flex-shrink: 0;
    color: var(--font-color-light);
}
.tree-view li.open > .toggle {
    transform: rotate(90deg);
}
.tree-root {
    font-weight: 600;
    display: block;
    padding: 4px 6px;
    text-decoration: none;
    color: var(--font-color);
}

/* --- 面包屑导航和头部按钮 --- */
.breadcrumbs {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.breadcrumbs a {
    text-decoration: none;
    color: var(--primary-color);
}
.breadcrumbs a:hover {
    text-decoration: underline;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* --- 上传模态框样式 --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0,0,0,.3);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}
.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}
.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--font-color-light);
}
.file-input-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
#upload-preview {
    margin-top: 1rem;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
}
#upload-preview ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

/* 响应式调整 */
@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 200px 1fr 250px;
    }
}

@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
    }
    .sidebar, .details-pane {
        display: none; /* 在移动端默认隐藏左右边栏 */
    }
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .header-actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }
    .user-info {
       display: flex;
       flex-direction: column;
       align-items: flex-end;
       gap: 0.25rem;
    }
    .file-browser table, .file-browser thead, .file-browser tbody, .file-browser th, .file-browser td, .file-browser tr {
        display: block;
    }
    .file-browser thead {
        display: none; /* 隐藏桌面版的表头 */
    }
    .file-browser tr {
        border-bottom: 1px solid var(--border-color);
        padding: 0.5rem 0;
    }
    .file-browser td {
        display: flex;
        justify-content: space-between;
        padding: 0.25rem 0.5rem;
        border: none;
    }
     .file-browser td:before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 1rem;
    }
    .file-browser td[data-label="文件名"] a {
        font-size: 1.1rem;
        font-weight: 600;
    }
     .file-browser td[data-label="文件名"]:before {
        display: none;
    }
} 